package JavaCodePublicClass.龟兔赛跑;

public class Rabbit extends Animal {
    //定义一个名字
    public Rabbit(){
        setName("兔子");
    }
    public void runing(){
        //兔子速度
        int dis=5;
        lenght-=dis;
        System.out.println("兔子跑了" + dis + "米.距离终点还有" + lenght + "米");
        if(lenght<=0){
            lenght=0;
            System.out.println("兔子胜利了!!!");
            if(calltoback!=null){
                calltoback.win();
            }
        }
        if((500-lenght)%20==0){
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }else {
            try {
                sleep(100);//兔子0.1秒奔跑的速度
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
